package com.social.service.impl;

import com.mzt.logapi.beans.Operator;
import com.mzt.logapi.service.IOperatorGetService;
import com.social.pojo.dto.UserDTO;
import com.social.service.SysUserService;
import com.social.utils.UserHolder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;
/**
 * @author zero
 */
@Service
public class DefaultOperatorGetServiceImpl implements IOperatorGetService {

    @Override
    public Operator getUser() {
        UserDTO user = UserHolder.getUser();
        return Optional.ofNullable(user)
                .map(u -> new Operator(u.getUsername()))
                .orElseThrow(()->new IllegalArgumentException("user is null"));
    }
}